package com;

import com.dao.StudentsMapper;
import com.pojo.Students;
import com.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

public class test {
    @Test
    public void testStudents() {
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        SqlSession sqlSession1 = MybatisUtils.getSqlSession();
        StudentsMapper studentsMapper = sqlSession.getMapper(StudentsMapper.class);

        Students students = studentsMapper.findAllStudents(1);
        Students students1=studentsMapper.findAllStudents(1);
        System.out.println(students);
        //默认使用一级缓存
        System.out.println(students==students1);
        sqlSession.close();


        Students students2 = sqlSession1.getMapper(StudentsMapper.class).findAllStudents(1);
        System.out.println(students2);
        System.out.println(students2==students);

        sqlSession1.close();

    }
}
